package com.xxg.renrensearch.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 店铺Dao
 *
 * @author xuxiaogang
 * @date 2021-11-17
 */
@Mapper
@Component
public interface RenrenShopShopDao {
    /**
     * 获取店铺ID最大值
     *
     * @return 结果
     */
    @Select("select max(id) from renren_shop_shop")
    int getMaxId();

    /**
     * 按照id范围获取店铺信息
     *
     * @param start 开始ID
     * @param end   结束ID
     * @return 结果
     */
    @Select("select id,user_id as userId,name,logo,is_deleted as isDeleted from renren_shop_shop where id between #{start} and #{end} and audit_status=10 and is_trial = 0")
    List<RenrenShopShop> selectByIdRange(@Param("start") int start, @Param("end") int end);


    @Select({"<script>",
            "select id,user_id as userId,name,logo,is_deleted as isDeleted",
            "from renren_shop_shop where id in",
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"})
    List<RenrenShopShop> selectByIds(@Param("ids") List<Integer> ids);
}